package org.sport.repository;

import org.sport.model.entityModel.GrouptableEntity;
import org.sport.model.entityModel.HistoryinfotableEntity;
import org.sport.model.entityModel.LinkapplyhistoryEntity;
import org.sport.model.entityModel.UsertableEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


@Repository
public interface HistoryinfotableRepository extends JpaRepository<HistoryinfotableEntity,Integer> {



    @Transactional
    @Query("select hisWho2Who from HistoryinfotableEntity hisWho2Who where hisWho2Who.usertableByUserId =?1 and hisWho2Who.usertableByToWhoId =?2")
    public List<HistoryinfotableEntity> findByWhoToWho(UsertableEntity who,UsertableEntity toWho);



    @Transactional
    @Query("select hisWho2Who from HistoryinfotableEntity hisWho2Who where hisWho2Who.grouptableByGroupId =?1")
    public List<HistoryinfotableEntity> findByGroupId(GrouptableEntity grouptableEntity);


    @Transactional
    @Query("select hisWho from HistoryinfotableEntity hisWho where hisWho.usertableByUserId =?1")
    public List<HistoryinfotableEntity> findByUserId(UsertableEntity who);

}
